{% extends "base.html" %}
{% block title %}个人信息管理{% endblock %}

{% block content %}
    <h2 class="mb-4">个人信息管理</h2>
    <form method="post">
        <!-- 年龄 -->
        <div class="mb-3">
            <label for="age" class="form-label">年龄</label>
            <input
                type="number"
                class="form-control"
                id="age"
                name="age"
                value="{{ user.age }}"
                required
            >
        </div>

        <!-- 性别 -->
        <div class="mb-3">
            <label for="gender" class="form-label">性别</label>
            <select
                class="form-select"
                id="gender"
                name="gender"
                required
            >
                <option value="Male"
                    {% if user.gender == 'Male' %}selected{% endif %}
                >Male</option>
                <option value="Female"
                    {% if user.gender == 'Female' %}selected{% endif %}
                >Female</option>
                <option value="Other"
                    {% if user.gender == 'Other' %}selected{% endif %}
                >Other</option>
            </select>
        </div>

        <!-- 身高 -->
        <div class="mb-3">
            <label for="height" class="form-label">身高（m）</label>
            <input
                type="number"
                step="0.01"
                class="form-control"
                id="height"
                name="height"
                value="{{ user.height }}"
                required
            >
        </div>

        <!-- 体重 -->
        <div class="mb-3">
            <label for="weight" class="form-label">体重（kg）</label>
            <input
                type="number"
                step="0.01"
                class="form-control"
                id="weight"
                name="weight"
                value="{{ user.weight }}"
                required
            >
        </div>

        <!-- 糖尿病类型 -->
        <div class="mb-3">
            <label for="diabetes_type" class="form-label">糖尿病类型</label>
            <select
                class="form-select"
                id="diabetes_type"
                name="diabetes_type"
                required
            >
                <option value="Type1"
                    {% if user.diabetes_type == 'Type1' %}selected{% endif %}
                >Type1</option>
                <option value="Type2"
                    {% if user.diabetes_type == 'Type2' %}selected{% endif %}
                >Type2</option>
            </select>
        </div>

        <!-- 高血压 -->
        <div class="mb-3 form-check">
            <input
                type="checkbox"
                class="form-check-input"
                id="hypertension"
                name="hypertension"
                {% if user.hypertension %}checked{% endif %}
            >
            <label class="form-check-label" for="hypertension">高血压</label>
        </div>

        <!-- 吸烟史 -->
        <div class="mb-3 form-check">
            <input
                type="checkbox"
                class="form-check-input"
                id="smoking_history"
                name="smoking_history"
                {% if user.smoking_history %}checked{% endif %}
            >
            <label class="form-check-label" for="smoking_history">吸烟史</label>
        </div>

        <!-- 遗传因素 -->
        <div class="mb-3 form-check">
            <input
                type="checkbox"
                class="form-check-input"
                id="genetic_factor"
                name="genetic_factor"
                {% if user.genetic_factor %}checked{% endif %}
            >
            <label class="form-check-label" for="genetic_factor">遗传因素</label>
        </div>

        <button type="submit" class="btn btn-primary">保存修改</button>
    </form>
{% endblock %}